package com.meitutest.autoscript.fluency;

import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;

import com.meitutest.autoscript.utils.TestReport;

/**
 * Created by CrystalChen on 2018/1/10.
 */

public class SlideWatcher{
    UiDevice mDevice;

    public SlideWatcher(UiDevice mDevice) {
        this.mDevice = mDevice;
    }

    public boolean checkForCondition() {
        if (mDevice.hasObject(By.text("同意|允许|以后再说|确定|以后再说|Ok|ok|OK|ALLOW|allow"))) {
            mDevice.findObject(By.text("同意|允许|以后再说|确定|以后再说|Ok|ok|OK|ALLOW|allow")).click();
            TestReport.i("MyWatcher_checkForCondition: 发现弹窗");
            return true;
        } else if (mDevice.hasObject(By.text("给我们评分"))) {
            mDevice.findObject(By.text("不了，谢谢")).click();
            TestReport.i("MyWatcher_checkForCondition: 发现弹窗-给我们评分，点击不了，谢谢");
            return true;
        }else if (mDevice.hasObject(By.text("淘宝"))) {
            mDevice.findObject(By.text("同意")).click();
            TestReport.i("MyWatcher_checkForCondition: 发现弹窗-淘宝责任弹窗，点击同意");
            return true;
        }
        return false;
    }
}